<html lang="zh">
<head>
    <link rel="icon" href="/static/images/title/air酱.ico" type="image/x-icon">
    <link rel="shortcut icon" href="/static/images/title/air酱.ico" type="image/x-icon">
    <meta charset="utf-8">
    <title>Air酱</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="/static/css/air-index.css" type="text/css" rel="stylesheet">
    <script src="/static/js/jquery-3.5.1.js"></script>
    <link href="/static/css/crawler.css" rel="stylesheet" type="text/css"/>

</head>
<body>
<div class="air-body">
    <div class="air-box">
        <div class="air-top-fix"></div>
        <div class="air-top">
            <a href="/" class="air-top-title">Air酱</a>
            <a href="/" class="air-top-a">首页</a>
            <a href="crawler" class="air-top-a">爬取机票</a>
            <a href="wechat" class="air-top-a">微信推送</a>
            <a id="login" href="login" class="air-top-a">登录</a>
        </div>
        <div class="air-top-fix"></div>
        <div class="air-center">
            <h3 class="air-SCKEY">微信推送码</h3>
            <p>您的SCKEY如下</p>
            <pre id="SCKEY"></pre>

            <h3 style="color: #ff6c9d">重新绑定推送码</h3>
            <form method="post" action="modify_sckey" onsubmit="return change()">
                {% csrf_token %}
                <input type="text" name="SCKEY">
                <input type="submit" value="重新绑定">
            </form>
        </div>

        <div class="air-down">

        </div>
    </div>


</div>

{% csrf_token %}
</body>
<script>
    window.onload = function cookie_load() {
        var acookie = document.cookie.split(';')
        let valueOf = document.getElementsByName('csrfmiddlewaretoken')[0].value
        var flag = 0;
        let login_id = document.getElementById('login');
        for (var i = 0; i < acookie.length; i++) {
            var strings = acookie[i].split('=');
            if (strings[0] === ' login-cookie') {
                flag = 1;
                $.post('logging', {
                    strings,
                    csrfmiddlewaretoken: valueOf
                }, function (data) {
                    login_id.innerText = '退出';
                    login_id.href = 'exitLogin';
                })
                $.post('find_sckey', {
                    strings,
                    csrfmiddlewaretoken: valueOf
                }, function (data) {
                    let SCKEY = window.document.getElementById('SCKEY');
                    SCKEY.innerText = data.SCKEY;
                })
            }
        }
        if (flag === 0) {
            login_id.innerText = '登录';
            login_id.href = 'login';
            window.location.href = 'login'
        }


    }
</script>
</html>